/*
 *  debugScene.h
 *  opencvExample
 *
 *  Created by 真鍋 大度 on 11/03/02.
 *  Copyright 2011 Rhizomatiks. All rights reserved.
 *
 */
#pragma once
#include "ofMain.h"
#include "basePattern.h"


class debugScene : public basePattern{
public:
	void setup(){
		allocate();
		//		numCheck = 8;	
		numCheckX = 8;
		numCheckY = 8;		
		unsigned char tmpval;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (i%2==0) {					
					unsigned char tmpval = i % numCheckY < numCheckY/2 
					? (j + w * i) % numCheckX < numCheckX/2 
					? maxGray : 0  :  (j + w * i) % numCheckX < numCheckX/2 
					? 0 : maxGray;								
				}
//				else {
//					tmpval = 255;
//				}
				//				unsigned char tmpval = j<w/2 ? count : 255 - count;
				currentColorPixels[(i*w+j)*3 + 0] = tmpval;
				currentColorPixels[(i*w+j)*3 + 1] = tmpval;
				currentColorPixels[(i*w+j)*3 + 2] = tmpval;		
			}
		}
	}
	void update(){
		unsigned char tmpval;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
			
			if (i%2==0) {
//				tmpval = i % numCheckY < numCheckY/2 
//				? (j + w * i) % numCheckY < numCheckY/2 
//				? 0 : maxGray  :  (j + w * i) % numCheckX < numCheckX/2 
//				? maxGray : 0;								
				tmpval = maxGray;
			}
			else{
				tmpval = i % numCheckY < numCheckY/2 
				? (j + w * i) % numCheckY < numCheckY/2 
				? maxGray : 0  :  (j + w * i) % numCheckX < numCheckX/2 
				? 0 : maxGray;								
			}
			
			currentColorPixels[(i*w+j)*3 + 0] = tmpval;
			currentColorPixels[(i*w+j)*3 + 1] = tmpval;
			currentColorPixels[(i*w+j)*3 + 2] = tmpval;		
			}
		}
		
		currentColorImage.setFromPixels(currentColorPixels, w, h);	
		count++;
	}
	void setupWhenPatternChanged(){
		count = 0;
	}
	int count;
	int numCheckX,numCheckY;
	
};
